using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;

namespace HSS.Xaml.UI.Controls.PropertyGridTestApp
{
	public partial class Home : Page
	{
		Person person;

		public Home()
		{
			InitializeComponent();
		}

		// Executes when the user navigates to this page.
		protected override void OnNavigatedTo(NavigationEventArgs e)
		{
			person = new Person
			{
				String = "Bill Gates",
				Datetime = new DateTime(1985, 8, 9),
				Int = -42,
				Short = 21,
				Long = -2878987,
				Uint = 324,
				Ushort = 21,
				Ulong = 21422,
				Car = new Car(),
				Cars = new List<Car>()
			};

			person.Cars.Add(new Car() { Brand = "Porche", Type = Car.CarType.Sport });
			person.Cars.Add(new Car() { Brand = "Honda", Type = Car.CarType.StationWagon });
			person.Cars.Add(new Car() { Brand = "Toyota", Type = Car.CarType.SUV });

			this.propertyGrid.SelectedObject = person;
		}

		private void test_Click(object sender, RoutedEventArgs e)
		{
			if (this.propertyGrid.SelectedObject == this.person)
				this.propertyGrid.SelectedObject = this.test;
			else
				this.propertyGrid.SelectedObject = this.person;
		}
	}
}
